// FieldByIndex
package main

import (
    "reflect"
    "fmt"
)

type Student struct {
    Id int
    Name string
    Sex bool
    Grade float32
}

type Monitor struct {
    Student
    As string
}

func main() {
    stu := Monitor{Student{10001,"李明", false, 90.5}, "班长"}
    t := reflect.TypeOf(stu)
    v := reflect.ValueOf(stu)
    for i:= 0; i <t.NumField();i++ {
        if t.Field(i).Anonymous {
            for j:=0;j<v.Field(i).NumField(); j++{
                fmt.Println("Embedded fields:", v.FieldByIndex([]int{i,j}).Interface())
            }
        } else {
            fmt.Println("Normal fields:", v.Field(i).Interface())
        }
    }
}